package fr.unice.polytech.plim.pedometre;

import android.util.Log;


public class CaloriesNotification implements PasListener {

    public interface Listener {
        public void valueChanged(float value);
        public void passValue();
    }
    private Listener mListener;    
    private double mCalories = 0;
    
    ReglagesPedometre mSettings;
    
    boolean mIsMetric;
    boolean mIsRunning;
    float mStepLength;
    float mBodyWeight;
    int cpt = 0;

    public CaloriesNotification(Listener listener, ReglagesPedometre settings) {
        mListener = listener;
        mSettings = settings;
        reloadSettings();
    }
    public void setCalories(float calories) {
        mCalories = calories;
        notifyListener();
    }
    public void reloadSettings() {
        mIsMetric = mSettings.isMetric();
        mIsRunning = mSettings.isRunning();
        mStepLength = mSettings.getStepLength();
        mBodyWeight = mSettings.getBodyWeight();
        notifyListener();
    }
    public void resetValues() {
        mCalories = 0;
    }
    
    public void isMetric(boolean isMetric) {
        mIsMetric = isMetric;
    }
    public void setStepLength(float stepLength) {
        mStepLength = stepLength;
    }
    
    public void onStep() {
        Log.i("nono", "cpt = "+ cpt);
    	if(cpt >= 19){
        	cpt = 0;
        	mCalories++;
        	notifyListener();
        }
        else{
        	cpt++;
        }
        
    }
    
    private void notifyListener() {
        mListener.valueChanged((float)mCalories);
    }
    
    public void passValue() {
        
    }
}

